package com.ems.mapper;

import com.ems.entity.BatteryVoltageEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ems.vo.BatteryVoltageVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 电池电压 Mapper 接口
 * </p>
 * @author WuZH
 * @since 2024-04-23
 */
@Mapper
public interface BatteryVoltageMapper extends BaseMapper<BatteryVoltageEntity> {

    @Select (value = "<script>SELECT * FROM battery_voltage_info bvi JOIN(SELECT deviceAddress, max(createTime) AS createTime FROM battery_voltage_info GROUP BY deviceAddress) bvii \n" +
            "ON bvi.deviceAddress=bvii.deviceAddress AND bvi.createTime=bvii.createTime\n" +
            "ORDER BY bvi.createTime DESC</script>")
    List<BatteryVoltageVo> queryList (@Param ("batteryVoltageVo") BatteryVoltageVo batteryVoltageVo);

    @Select ( value = "SELECT COUNT(1) FROM battery_box_info")
    Integer queryCount(@Param ("batteryVoltageVo") BatteryVoltageVo batteryVoltageVo);

}
